const http = require('../../../utils/httpUtils.js')
const app = getApp();
Page({
    data: {
        navbarData: {
            showCapsule: 1, //是否显示左上角图标
            title: '绑定推荐人' //导航栏 中间的标题
        },
        height: app.globalData.height * 2 + 20
    },
    onLoad() {

    },
    onShow() {

    },
    bindKeyInput(e) {
        this.setData({
            inputValue: e.detail.value
        })
    },
    rem() {
        if (isNaN(this.data.inputValue) || this.data.inputValue.length != 11) {
            wx.showModal({
                title: '提示',
                content: '手机号码格式不对',
                showCancel: false
            })
            return
        }
        http._headerPost('/api/user/bind_phone', {
            c_client: "weixinSmall",
            phone: this.data.inputValue
        }, res => {
            if (res.data.code == 1) {
                wx.showModal({
                    title: '提示',
                    content: '添加成功',
                    showCancel: false,
                    success(res) {
                        wx.navigateBack({
                            delta: 2
                        })
                    }
                })
            } else {
                wx.showToast({
                    title: res.data.msg,
                    icon: 'none'
                })
            }
        })
    }
})